var KeyboardManager = function()
{
	this.keydown = function(e)
	{
		switch(e.keyCode)
		{
			case 32:
				if(sceneManager.currentScene == "game")
					player.Space = true;
				break;
		
			case 39:
				if(sceneManager.currentScene == "game")
				{
					player.KeyRight = true;
					player.KeyLeft = false;
				}
				break;
				
			case 37:
				if(sceneManager.currentScene == "game")
				{
					player.KeyLeft = true;
					player.KeyRight = false;
				}
				break;
				
			case 40:
				if(sceneManager.currentScene == "game")
				{
					player.KeyDown = true;
					player.KeyUp = false;
				}
				break;
				
			case 38:
				if(sceneManager.currentScene == "game")
				{
					player.KeyUp = true;
					player.KeyDown = false;
				}
				break;
				
			case 27:
				if(sceneManager.currentScene != "opening")
				{
					sceneManager.pause = false;
					sceneManager.Opening();
				}
				break;
		}
	}
	
	this.keyup = function(e)
	{
		switch(e.keyCode)
		{			
			case 32:
				if(sceneManager.currentScene == "game")
				{
					player.Space = false;
					windows.collision = true;
				}
			break;
		}
	}
}

var keyboard = new KeyboardManager();

document.addEventListener('keydown', keyboard.keydown, true);	
document.addEventListener('keyup', keyboard.keyup, true);